package com.hl.payServer.model;

public class ResultModel {
    private boolean success;
    /**
     * 返回码
     */
    private int code;

    /**
     * 返回结果描述
     */
    private String message;

    /**
     * 返回内容
     */
    private Object content;

    public static ResultModel ok(Object content) {
        return new ResultModel(ResultStatus.SUCCESS, content);
    }

    public static ResultModel ok() {
        return new ResultModel(ResultStatus.SUCCESS);
    }

    public static ResultModel error(ResultStatus error,Object content) {
        return new ResultModel(error,content);
    }

    public ResultModel(ResultStatus status) {
        this.code = status.getCode();
        this.message = status.getMessage();
        this.content = "";
        if(ResultStatus.SUCCESS.equals(status)){
            this.success = true;
        }else{
            this.success = false;
        }
    }

    public ResultModel(ResultStatus status, Object content) {
        this.code = status.getCode();
        this.message = status.getMessage();
        this.content = content;
        if(ResultStatus.SUCCESS.equals(status)){
            this.success = true;
        }else{
            this.success = false;
        }
    }
    public ResultModel(boolean success, String message) {
        this(success, (Integer)null, message, (Object)null);
    }

    public ResultModel(boolean success, Integer code, String message, Object o) {
        this.success = success;
        this.message = message;
        this.code = code==null ? 0:code;
        this.content = o;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getContent() {
        return content;
    }

    public void setContent(Object content) {
        this.content = content;
    }
}
